﻿@using Partner.Surround
@model Partner.Surround.Web.Models.Account.LoginFormViewModel
@section Styles{
    <link href="~/lib/famfamfam-flags/dist/sprite/famfamfam-flags.css" rel="stylesheet" asp-append-version="true" />
    <link href="~/css/materialize.css" rel="stylesheet" asp-append-version="true" />
    <link href="~/css/login.css" rel="stylesheet" />
    <style type="text/css">
        body {
            background-color: #00bcd4 !important;
        }

        .layui-center {
            text-align: center;
        }

        .language-switch-area {
            text-align: center;
            padding: 10px;
        }

        .user-login-body {
            margin: 35px 15px;
        }

            .user-login-body .layui-form-item {
                position: relative;
            }

        .layui-icon-username {
            position: absolute;
            left: 1px;
            top: 1px;
            width: 38px;
            line-height: 36px;
            text-align: center;
            color: #d2d2d2;
        }

        .layui-icon-password {
            position: absolute;
            left: 1px;
            top: 1px;
            width: 38px;
            line-height: 36px;
            text-align: center;
            color: #d2d2d2;
        }

        .layui-form-item {
            margin-bottom: 15px;
        }
    </style>
}

<div class="login">
    <div class="layui-logo" style="font-size:36px;text-align: center;padding: 20px;">
        <a href="javascript:void(0);" style="color: #fff;">Surround</a>
    </div>

    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form user-login-body">
                <input type="hidden" name="returnUrl" value="@Model.ReturnUrl" />
                <input type="hidden" name="returnUrlHash" />
                <h3 class="layui-center" style="margin:10px 0;font-weight:bold;font-size:18px;">@L("LogIn")</h3>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="usernameOrEmailAddress" id="LAY-user-login-username" style="padding-left: 38px;" lay-verify="required" value="admin" placeholder="@L("UserNameOrEmail")" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" style="padding-left: 38px;" lay-verify="required" value="123qwe" placeholder="@L("Password")" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <input type="checkbox" name="rememberMe" id="rememberme" lay-skin="primary" title="@L("RememberMe")">
                    @if (Model.IsSelfRegistrationAllowed)
                    {
                        @*<a asp-action="Register" class="">@L("Register")</a>*@
                    }
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid layui-bg-blue" lay-submit lay-filter="LAY-user-login-submit">@L("LogIn")</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="layui-trans login-footer">
    <div class="layui-col-xs12 layui-text-center" style="color: #e9e9e9">
        <small>&copy; @DateTime.Now.Year Surround. <b>Version </b> @AppVersionHelper.Version [@AppVersionHelper.ReleaseDate.ToString("yyyyMMdd")]</small>
    </div>
    <vc:account-languages></vc:account-languages>
</div>

@section Scripts{
    <script type="text/javascript">
        layui.config({
            base: '/lib/layui-extend-modules/' //静态资源所在路径
        }).use(['jquery', 'form', 'layer', 'table'], function () {
            var $ = layui.$,
                form = layui.form;

            abp.multiTenancy.setTenantIdCookie(@ViewBag.TenantId);
            form.render();

            form.on('submit(LAY-user-login-submit)', function (data) {
                data.field.rememberMe = data.field.rememberMe == "on";//默认值是on
                var field = data.field; //获取提交的字段

                var waitIndex = layer.load(2);
                abp.ajax({
                    url: "@Url.Action("Login", "Account")",
                    data: JSON.stringify(field)
                }).always(function () {
                    layer.close(waitIndex);
                });

                return false;
            });
        });
    </script>
}
